package com.lagou.mr.partition;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;


public class PartitionBean implements Writable {
    private String id;
    private String deviceId;
    private String appKey;
    private String ip;
    private long selfDuration;
    private long thirdDuration;
    private String status;

    public PartitionBean() {
    }

    public PartitionBean(String id, String deviceId, String appKey, String ip, long selfDuration, long thirdDuration, String status) {
        this.id = id;
        this.deviceId = deviceId;
        this.appKey = appKey;
        this.ip = ip;
        this.selfDuration = selfDuration;
        this.thirdDuration = thirdDuration;
        this.status = status;
    }

    @Override
    public String toString() {
        return id  +
                "\t" + deviceId  +
                "\t" + appKey +
                "\t" + ip +
                "\t" + selfDuration +
                "\t" + thirdDuration +
                "\t" + status ;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public String getAppKey() {
        return appKey;
    }

    public void setAppKey(String appKey) {
        this.appKey = appKey;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public long getSelfDuration() {
        return selfDuration;
    }

    public void setSelfDuration(long selfDuration) {
        this.selfDuration = selfDuration;
    }

    public long getThirdDuration() {
        return thirdDuration;
    }

    public void setThirdDuration(long thirdDuration) {
        this.thirdDuration = thirdDuration;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    @Override
    public void write(DataOutput out) throws IOException {
        out.writeUTF(id);
        out.writeUTF(deviceId);
        out.writeUTF(appKey);
        out.writeUTF(ip);
        out.writeLong(selfDuration);
        out.writeLong(thirdDuration);
        out.writeUTF(status);
    }

    @Override
    public void readFields(DataInput in) throws IOException {
        this.id = in.readUTF();
        this.deviceId = in.readUTF();
        this.appKey = in.readUTF();
        this.ip = in.readUTF();
        this.selfDuration = in.readLong();
        this.thirdDuration = in.readLong();
        this.status = in.readUTF();
    }
}
